package com.zjdiepu.www.manage.view;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.status.LessInformationStatus;
import com.zjdiepu.www.base.enums.status.PhoneStatus;
import com.zjdiepu.www.base.enums.type.BusinessExtrasCodeType;
import com.zjdiepu.www.base.enums.type.BusinessExtrasType;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.commpent.ViewScopeControllerHelper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessDetailMapper;
import com.zjdiepu.www.ibiz.base.IDpBaseDataDictionaryService;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.cw.ICwRefundCarService;
import com.zjdiepu.www.ibiz.cw.ICwRemitCarService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessExtrasService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.ibiz.yw.IYwFeesSubService;
import com.zjdiepu.www.ibiz.yw.IYwFundApplyService;
import com.zjdiepu.www.ibiz.zx.IZxCreditQueryService;
import com.zjdiepu.www.model.base.dto.DpBaseDataDictionary;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.ext.DpBaseDataDictionaryExt;
import com.zjdiepu.www.model.cw.dto.CwRefundCar;
import com.zjdiepu.www.model.cw.response.CwFundItem;
import com.zjdiepu.www.model.yw.dto.YwBusinessExtras;
import com.zjdiepu.www.model.yw.dto.YwFundApply;
import com.zjdiepu.www.model.yw.ext.YwBusinessExt;
import com.zjdiepu.www.model.yw.response.YwBusinessBuyerItem;
import com.zjdiepu.www.model.yw.response.YwBusinessDetail;
import com.zjdiepu.www.model.zx.response.ZxCreditQueryDetail;
import com.zjdiepu.www.util.CachedEnums;
import com.zjdiepu.www.util.ExceptionHelper;
/**
 * 业务信息Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时43分<br/>
 * @since 1.0<br/>
 */
@Controller
@RequestMapping(value= "YwBusinessViewController", produces="text/html;charset=UTF-8")
@Api(tags = {"业务信息"}, produces="text/html;charset=UTF-8")
public class YwBusinessViewController extends BaseController {
	@Resource
    private ViewScopeControllerHelper viewScopeControllerHelper;
    @Resource
    private ICachedDictionaryService cachedDictionaryService;
    @Resource
	private IYwBusinessService ywBusinessService;
    @Resource
    private IYwFundApplyService ywFundApplyService;
    @Resource
    private IZxCreditQueryService zxCreditQueryService;
    @Resource
    private IDpBaseDataDictionaryService dBaseDataDictionaryService;
    @Resource
    private IYwFeesSubService ywFeesSubService;
    @Resource
    private IYwBusinessExtrasService ywBusinessExtrasService;
    @Resource
    private YwBusinessDetailMapper ywBusinessDetailMapper;
    @Resource
    private ICwRemitCarService cwRemitCarService;
    
    @Resource
	private ICwRefundCarService cwRefundCarService;
    /**
     * @author xiongxiaotun <br/>
     * @Title: multiUpload  <br/>
     * @Description: 多文件上传 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "多文件上传", httpMethod="GET", tags={"多文件上传"})
    @RequestMapping(value = "multiUpload", method = RequestMethod.GET)
    public String multiUpload(Model model) {
    	getCurrentUser();
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	return "demo/upload/custom";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: save  <br/>
     * @Description: 新增业务信息 <br/>
     * @param ywBusiness
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "资料登记客户派单", response = Boolean.class, httpMethod="GET", tags={"派单"})
    @RequestMapping(value = "allocation", method = RequestMethod.GET)
    public String informationAllocation(Model model) {
    	SysUser sysUser =(SysUser)getCurrentUser();
    	String orgId = sysUser.getOrgId();
    	List<SysUser> users = viewScopeControllerHelper.preparedAllocation(orgId, model);
    	
    	YwBusinessExt ywBusinessExt = new YwBusinessExt();
    	ywBusinessExt.setBaseWhere();
        ywBusinessExt.addBusiStatus(BusiStatus.ZI_LIAO_DENG_JI.getCode());
    	int countNotAllocation = ywBusinessService.countNotAllocation(ywBusinessExt);
    	model.addAttribute("countNotAllocation", countNotAllocation);
    	
    	int userCounts = users.size();
    	int avg  = countNotAllocation / userCounts + (countNotAllocation % userCounts == 0 ? 0 : 1);
    	model.addAttribute("avg", avg);
    	
    	return "system/yw/informationAllocation";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywSupplementBussinessDetail  <br/>
     * @Description: 资料补登记 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "资料补登记", response = Boolean.class, httpMethod="GET", tags={"新增"})
    @RequestMapping(value = "ywSupplementBussinessDetail", method = RequestMethod.GET)
    public String ywSupplementBussinessDetail(Model model, String id) {
    	if(StringUtils.isBlank(id)) {
    		ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
    	}
    	
    	//业务详情
    	YwBusinessDetail ywBusinessDetail = ywBusinessService.getMultiById(id);
    	if(ywBusinessDetail == null) {
    		ExceptionHelper.thow(ResultFlagType.MISSING);
    	}
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	// 查询征信信息
		String creditApplyId = ywBusinessDetail.getQueryCreditApplyId();
		if (StringUtils.isNotBlank(creditApplyId)) {
			List<ZxCreditQueryDetail> zxCrediQueryDetails = zxCreditQueryService.selectMultiByApplyId(creditApplyId);
			Map<String, List<YwBusinessBuyerItem>> ywBusinessBuyerItems = new LinkedHashMap<String, List<YwBusinessBuyerItem>>();
			for (ZxCreditQueryDetail zxCrediQueryDetail : zxCrediQueryDetails) {
				String creditPeopleType = zxCrediQueryDetail.getCreditPeopleType();
				List<YwBusinessBuyerItem> ywBusinessBuyerItems_ = ywBusinessBuyerItems.get(creditPeopleType);
				if(null == ywBusinessBuyerItems_) {
					ywBusinessBuyerItems_ = CollectionInitUtil.emptyList();
				}
				ywBusinessBuyerItems_.add(new YwBusinessBuyerItem(zxCrediQueryDetail.getCusName(), zxCrediQueryDetail.getCusNo()));
				ywBusinessBuyerItems.put(creditPeopleType, ywBusinessBuyerItems_);
			}
			model.addAttribute("ywBusinessBuyerItems", ywBusinessBuyerItems);
			model.addAttribute("busiStatusNames", CachedEnums.getNames(BusiStatus.class));
	    	model.addAttribute("phoneStatusNames", CachedEnums.getNames(PhoneStatus.class));
	    	model.addAttribute("lessInformationStatusNames", CachedEnums.getNames(LessInformationStatus.class));
	    	model.addAttribute("businessExtrasCodeTypeNames", CachedEnums.getNames(BusinessExtrasCodeType.class));
		}
    	return "system/yw/ywSupplementBussinessDetail";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywPostSupplementBussinessDetail  <br/>
     * @Description: 后补资料登记 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "后补资料登记", response = Boolean.class, httpMethod="GET", tags={"新增"})
    @RequestMapping(value = "ywPostSupplementBussinessDetail", method = RequestMethod.GET)
    public String ywPostSupplementBussinessDetail(Model model, String id) {
    	if(StringUtils.isBlank(id)) {
    		ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
    	}
    	
    	//业务详情
    	YwBusinessDetail ywBusinessDetail = ywBusinessService.getMultiById(id);
    	if(ywBusinessDetail == null) {
    		ExceptionHelper.thow(ResultFlagType.MISSING);
    	}
    	ywBusinessDetailMapper.mapper(ywBusinessDetail);
    	viewScopeControllerHelper.preparedNowTime(model);
    	model.addAttribute("ywBusinessDetail", ywBusinessDetail);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	return "system/yw/postSupplementDetail";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywBussinessDetail  <br/>
     * @Description: 新增业务信息 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "新增业务信息", response = Boolean.class, httpMethod="GET", tags={"新增"})
    @RequestMapping(value = "ywBussinessDetail", method = RequestMethod.GET)
    public String ywBussinessDetail(Model model, String id) {
    	//下拉选项
    	model.addAttribute("carCategoryType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_CATEGORY,"请选择..."));
    	model.addAttribute("maritalStatus", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.MARITAL_STATUS,"请选择..."));
    	model.addAttribute("dealerLevel", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.DEALER_LEVEL,"请选择..."));
    	model.addAttribute("educationType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.EDUCATION,"请选择..."));
    	model.addAttribute("sexType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.SEX,"请选择..."));
    	model.addAttribute("loanType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.LOAN_TYPE,"请选择..."));
    	model.addAttribute("loanBankType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.LOAN_BANK,"请选择..."));
    	model.addAttribute("licencePlateType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.LICENCE_PLATE_TYPE,"请选择..."));
    	model.addAttribute("carType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_TYPE,"请选择..."));
    	model.addAttribute("carPlaceType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_PLACE,"请选择..."));
    	model.addAttribute("loanMonthType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.LOAN_MONTH,"请选择..."));
    	model.addAttribute("jobType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.ZHI_WEI,"请选择..."));
    	model.addAttribute("workAgeType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.WORK_AGE,"请选择..."));
    	model.addAttribute("carStatus", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_STATUS,"请选择..."));
    	model.addAttribute("carPurpose", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_PURPOSE,"请选择..."));
    	model.addAttribute("channelType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CHANNEL_TYPE,"请选择..."));
    	model.addAttribute("channelStatus", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CHANNEL_STATUS,"请选择..."));
    	model.addAttribute("contactRelation", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CONTACT_RELATION,"请选择..."));
    	model.addAttribute("jobStatus", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.JOB_STATUS,"请选择..."));
    	model.addAttribute("affiliateStatus", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.AFFILIATE_STATUS,"请选择..."));
    	
    	
    	model.addAttribute("CHU_SHEN_DAN_CHU_SHEN_ZHONG", BusiStatus.CHU_SHEN_DAN_CHU_SHEN_ZHONG.getCode());
    	model.addAttribute("QIAN_SHU_HE_TONG_ZHONG", BusiStatus.QIAN_SHU_HE_TONG_ZHONG.getCode());
    	
    	
    	model.addAttribute("ADD_GPS_TYPE", BusinessExtrasType.AUDIT.getCode());
    	model.addAttribute("ADD_GPS_CODE", BusinessExtrasCodeType.ADD_GPS.getCode());
    	model.addAttribute("ADD_GPS_NAME", BusinessExtrasCodeType.ADD_GPS.getValue());
    	
    	//判断条件
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(id, model);
    	if(ywBusinessDetail != null) {
    		viewScopeControllerHelper.preparedHistoryBusiness(ywBusinessDetail.getCustomerNo(), model);
    	}
    	viewScopeControllerHelper.preparedRegin(model,null,null);
    	viewScopeControllerHelper.preparedCarModel(model);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
		
    	YwBusinessExtras ywBusinessExtras_ = new YwBusinessExtras();
    	ywBusinessExtras_.setBusiId(id);
    	ywBusinessExtras_.setTypeExtras(BusinessExtrasType.PHONE_AUDIT.getCode());
    	ywBusinessExtras_.setCodeExtras(BusinessExtrasCodeType.IS_PHONE_AUDIT.getCode());
    	ywBusinessExtras_.setDpStatus(DpStatus.NORMAL.getCode());
    	YwBusinessExtras ywBusinessExtras = ywBusinessExtrasService.selectRefined(ywBusinessExtras_);
    	if(null != ywBusinessExtras) {
    		model.addAttribute("ifPhone", "1".equals(ywBusinessExtras.getValueExtras()));
    	}
    	
    	ywBusinessExtras_.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
    	ywBusinessExtras_.setCodeExtras(BusinessExtrasCodeType.ADD_GPS.getCode());
    	YwBusinessExtras addGps = ywBusinessExtrasService.selectRefined(ywBusinessExtras_);
    	if(null != addGps) {
    		model.addAttribute("addGps", addGps);
    	}
    	
    	// 查询征信信息
		String creditApplyId = ywBusinessDetail.getQueryCreditApplyId();
		if (StringUtils.isNotBlank(creditApplyId)) {
			List<ZxCreditQueryDetail> zxCrediQueryDetails = zxCreditQueryService.selectMultiByApplyId(creditApplyId);
			Map<String, List<YwBusinessBuyerItem>> ywBusinessBuyerItems = new LinkedHashMap<String, List<YwBusinessBuyerItem>>();
			int i = 1;
			for (ZxCreditQueryDetail zxCrediQueryDetail : zxCrediQueryDetails) {
				String creditPeopleType = zxCrediQueryDetail.getCreditPeopleType();
				String cusNo = zxCrediQueryDetail.getCusNo();
				if("01".equals(creditPeopleType)) {
					model.addAttribute("PEI_OU_CUS_NO", cusNo);
				} else if("03".equals(creditPeopleType)) {
					model.addAttribute("CUS_NO", cusNo);
				} else {
					model.addAttribute("DAN_BAO_REN_CUS_NO_" + i, cusNo);
					i++;
				}
				List<YwBusinessBuyerItem> ywBusinessBuyerItems_ = ywBusinessBuyerItems.get(creditPeopleType);
				if(null == ywBusinessBuyerItems_) {
					ywBusinessBuyerItems_ = CollectionInitUtil.emptyList();
				}
				ywBusinessBuyerItems_.add(new YwBusinessBuyerItem(zxCrediQueryDetail.getCusName(), zxCrediQueryDetail.getCusNo()));
				ywBusinessBuyerItems.put(creditPeopleType, ywBusinessBuyerItems_);
			}
			model.addAttribute("ywBusinessBuyerItems", ywBusinessBuyerItems);
		}
    			
        return "system/yw/ywBussinessDetail";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: signContractDetail  <br/>
     * @Description: 签署合同详情 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "签署合同详情", response = Boolean.class, httpMethod="GET", tags={"签署合同"})
    @RequestMapping(value = "signContractDetail", method = RequestMethod.GET)
    public String signContractDetail(Model model, String id) {
    	if (StringUtils.isBlank(id)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	viewScopeControllerHelper.preparedBusiness(id, model);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	viewScopeControllerHelper.preparedNowTime(model);
    	return "system/yw/signContractDetail";
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: applyLoanDetail  <br/>
     * @Description: 申请垫资详情 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "申请垫资详情", response = Boolean.class, httpMethod="GET", tags={"申请垫资"})
    @RequestMapping(value = "applyLoanDetail", method = RequestMethod.GET)
    public String applyLoanDetail(Model model, String id) {
    	if (StringUtils.isBlank(id)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	model.addAttribute("settlementType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.SETTLEMENT_TYPE,"请选择..."));
    	
    	viewScopeControllerHelper.preparedNowTime(model);
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(id, model);
    	if(ywBusinessDetail != null){
    		viewScopeControllerHelper.preparedYwFee(id, ywBusinessDetail.getCustomerId(), model);
    		YwFundApply applyNotRemit = ywFundApplyService.getApplyNotRemit(id);
    		if(null !=  applyNotRemit) {
    			model.addAttribute("ywFundApply",  applyNotRemit);
    		}
//    		viewScopeControllerHelper.preparedFundApply(id, ywBusinessDetail.getCustomerId(),ywBusinessDetail.getAddedStatus1(), true, model);
    	}
    	
//    	获取费用数据字典=====================
    	DpBaseDataDictionaryExt dpBaseDataDictionaryExt = new DpBaseDataDictionaryExt();
    	dpBaseDataDictionaryExt.setBaseWhere();
    	dpBaseDataDictionaryExt.withOutPage();
    	dpBaseDataDictionaryExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	dpBaseDataDictionaryExt.setAddedValue1("01"); //启用的明细
    	dpBaseDataDictionaryExt.setOrderSql("`VALUE`");
//		只展示附加值为1的数据
    	List<DpBaseDataDictionary> dpBaseDataDictionarys = dBaseDataDictionaryService.selectByExt(dpBaseDataDictionaryExt);
    	
    	DpBaseDataDictionaryExt depositItemExt = new DpBaseDataDictionaryExt();
    	depositItemExt.setBaseWhere();
    	depositItemExt.setRows(1);
    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	depositItemExt.setValue("35");
    	List<DpBaseDataDictionary> depositDataDictionaryItems = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems)) {
    		dpBaseDataDictionarys.add(depositDataDictionaryItems.get(0));
    	} else {
    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    		dpBaseDataDictionary.setValue("35");
    		dpBaseDataDictionary.setName("征信押金");
    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	}
    	depositItemExt.setBaseWhere();
    	depositItemExt.setRows(1);
    	depositItemExt.setParentValue(DataDicType.FUND_ITEM.getCode());
    	depositItemExt.setValue("01");
    	List<DpBaseDataDictionary> depositDataDictionaryItems_ = dBaseDataDictionaryService.selectByExt(depositItemExt);
    	if(CollectionUtils.isNotEmpty(depositDataDictionaryItems_)) {
    		dpBaseDataDictionarys.add(depositDataDictionaryItems_.get(0));
    	} else {
    		DpBaseDataDictionary dpBaseDataDictionary = new DpBaseDataDictionary();
    		dpBaseDataDictionary.setValue("01");
    		dpBaseDataDictionary.setName("按揭服务费");
    		dpBaseDataDictionary.setParentValue(DataDicType.FUND_ITEM.getCode());
    		dpBaseDataDictionarys.add(dpBaseDataDictionary);
    	}
//    	获取费用数据字典=====================
    	
    	
//    	==================应收获取============================
    	List<Map<String, Double>> fees = ywFeesSubService.countReceiveByBusiId(id, null);
//    	==================应收获取============================
    	
//    	==================已收获取============================   	
    	List<String> exludeKeys = Arrays.asList(new String[]{"01", "35"});
    	List<CwFundItem> fundItems = CollectionInitUtil.emptyList();
    	List<CwFundItem> fundItems_ = CollectionInitUtil.emptyList();
    	if(CollectionUtils.isNotEmpty(dpBaseDataDictionarys)) {
    		for(DpBaseDataDictionary dpBaseDataDictionary : dpBaseDataDictionarys) {
    			CwFundItem cwFundItem = new CwFundItem();
    			String key = dpBaseDataDictionary.getValue();
    			cwFundItem.setKey(key);
    			cwFundItem.setName(dpBaseDataDictionary.getName());
    			cwFundItem.setFeeCount(ViewScopeControllerHelper.getItem(fees, key));
    			if(exludeKeys.contains(key)) {
    				fundItems_.add(cwFundItem);
    			} else {
    				fundItems.add(cwFundItem);
    			}
    		}
    	}
    	
    	String history = cwRemitCarService.queryHistoryByBusiId(id);
    	model.addAttribute("history", StringUtils.isBlank(history)?"-":(history.startsWith(",")?history.substring(1):history));
    	
    	//add by zzj 增加退提车款时间
    	CwRefundCar cwRefundCar= new CwRefundCar();
    	cwRefundCar.setBusiId(id);
    	cwRefundCar.setDpStatus(DpStatus.NORMAL.getCode());
    	cwRefundCar=cwRefundCarService.selectRefined(cwRefundCar);
    	model.addAttribute("cwRefundCar", cwRefundCar);
    	
//    	==================已收获取============================  
    	model.addAttribute("fundItems", fundItems);
    	model.addAttribute("fundItems_", fundItems_);
    	
    	CwFundItem cwFundItem = new CwFundItem();
    	cwFundItem.setFeeCount(ViewScopeControllerHelper.countItems(fees, null));
    	model.addAttribute("fundTotal", cwFundItem);
    	
    	int size = fundItems.size();
    	int tBodyCount =  size % 7 == 0 ? size / 7 : size / 7 + 1;
    	List<Integer> loopPlaceholders = CollectionInitUtil.emptyList();
    	for(int i = 0; i < tBodyCount; i++) {
    		loopPlaceholders.add(i);
    	}
    	model.addAttribute("loopPlaceholders", loopPlaceholders);
		
    	return "system/yw/applyLoanDetail";
    }

}
